using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class GadgetItemsInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Parent,
			Name,
			Description,
			Link,
			Type,
			Rank,
			Target,
			IsDefault,
			IsNew
		}
		private Int32 _ID;
		private String _Parent;
		private String _Name;
		private String _Description;
		private String _Link;
		private String _Type;
		private Int32 _Rank;
		private String _Target;
		private String _IsDefault;
		private String _IsNew;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Parent{	get{ return _Parent;} set{_Parent = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String Description{	get{ return _Description;} set{_Description = value;} }
		public String Link{	get{ return _Link;} set{_Link = value;} }
		public String Type{	get{ return _Type;} set{_Type = value;} }
		public Int32 Rank{	get{ return _Rank;} set{_Rank = value;} }
		public String Target{	get{ return _Target;} set{_Target = value;} }
		public String IsDefault{	get{ return _IsDefault;} set{_IsDefault = value;} }
		public String IsNew{	get{ return _IsNew;} set{_IsNew = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public GadgetItemsInfo()
		{
			_ID = 0;
			_Parent = "";
			_Name = "";
			_Description = "";
			_Link = "";
			_Type = "";
			_Rank = 0;
			_Target = "";
			_IsDefault = "";
			_IsNew = "";
		}
		public GadgetItemsInfo(
		Int32 ID,
		String Parent,
		String Name,
		String Description,
		String Link,
		String Type,
		Int32 Rank,
		String Target,
		String IsDefault,
		String IsNew
		)
		{
			_ID = ID;
			_Parent = Parent;
			_Name = Name;
			_Description = Description;
			_Link = Link;
			_Type = Type;
			_Rank = Rank;
			_Target = Target;
			_IsDefault = IsDefault;
			_IsNew = IsNew;
		}
		public GadgetItemsInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Parent = dr[Field.Parent.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Parent.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_Description = dr[Field.Description.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Description.ToString()]);
				_Link = dr[Field.Link.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Link.ToString()]);
				_Type = dr[Field.Type.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Type.ToString()]);
				_Rank = dr[Field.Rank.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.Rank.ToString()]);
				_Target = dr[Field.Target.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Target.ToString()]);
				_IsDefault = dr[Field.IsDefault.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.IsDefault.ToString()]);
				_IsNew = dr[Field.IsNew.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.IsNew.ToString()]);
			}
		}
		public GadgetItemsInfo(GadgetItemsInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Parent = objEntr.Parent;			
			_Name = objEntr.Name;			
			_Description = objEntr.Description;			
			_Link = objEntr.Link;			
			_Type = objEntr.Type;			
			_Rank = objEntr.Rank;			
			_Target = objEntr.Target;			
			_IsDefault = objEntr.IsDefault;			
			_IsNew = objEntr.IsNew;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("GadgetItems");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Parent.ToString(), typeof(String)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.Description.ToString(), typeof(String)),
				new DataColumn(Field.Link.ToString(), typeof(String)),
				new DataColumn(Field.Type.ToString(), typeof(String)),
				new DataColumn(Field.Rank.ToString(), typeof(Int32)),
				new DataColumn(Field.Target.ToString(), typeof(String)),
				new DataColumn(Field.IsDefault.ToString(), typeof(String)),
				new DataColumn(Field.IsNew.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Parent.ToString()] = _Parent;
			row[Field.Name.ToString()] = _Name;
			row[Field.Description.ToString()] = _Description;
			row[Field.Link.ToString()] = _Link;
			row[Field.Type.ToString()] = _Type;
			row[Field.Rank.ToString()] = _Rank;
			row[Field.Target.ToString()] = _Target;
			row[Field.IsDefault.ToString()] = _IsDefault;
			row[Field.IsNew.ToString()] = _IsNew;
			return row;
		}
        #endregion InitTable
    }
}
